package pedongi.mobile.colorfinder;

import pedongi.mobile.colorfinder.knowledgebase.KnowledgeBaseDriver;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TabHost;

public class MainActivity extends TabActivity {
	private ImageButton findButton;
	private ImageButton editKnowledgeButton;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        TabHost tabHost = getTabHost();
		TabHost.TabSpec spec;
		Intent intent;
		
		//Add MainActivity Tab
		intent = new Intent().setClass(this, FindActivity.class);
		spec = tabHost.newTabSpec("main").setIndicator("Find Answer").setContent(intent);
		tabHost.addTab(spec);
		
		//Add MapActivity Tab
		intent = new Intent().setClass(this, EditKnowledgeActivity.class);
		spec = tabHost.newTabSpec("map").setIndicator("Edit Knowledge").setContent(intent);
		tabHost.addTab(spec);
		
		//Set current tab : MainActivity Tab
		tabHost.setCurrentTab(0);
        
        ///INIT
        //findButton = (ImageButton) findViewById(R.id.findButton);
        //editKnowledgeButton = (ImageButton) findViewById(R.id.editKnowledgeButton);
        
        KnowledgeBaseDriver.getInstance().setPref(getSharedPreferences(EditKnowledgeActivity.KB_PREF, 0));
        
        //setListener();
    }
    
    private void setListener() {
    	findButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(MainActivity.this.getApplicationContext() , FindActivity.class));
			}
		});
    	
    	editKnowledgeButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(MainActivity.this.getApplicationContext() , EditKnowledgeActivity.class));
			}
		});
    }
}